Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daniela Sanchez - Paper #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

danisandiaz
Copy link

Hash Table Practice

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
Why is a good Hash Function Important? A good hash function is important is because it can determine how secure your code is. It can also impact efficiency.
How can you judge if a hash function is good or not? You can judge a hash function based on how it distributes the data it takes in. For example: how does it handle capacity? How does it handle collisions.
Is there a perfect hash function? If so what is it? I don't think so. A complexity of hash functions increase and make them more secure, the computing power of computers also increases and their availability to break hash functions. So better hash function always be needed.
Describe a strategy to handle collisions in a hash table You can handle collisions by chaining. In this strategy, you can house several items that point to the same cell by using a linked list.
Describe a situation where a hash table wouldn't be as useful as a binary search tree In a situation that you need to have the data sorted a BST would be more useful.
What is one thing that is more clear to you on hash tables now Hash table are much more applicable than I thought. They can be used to quickly find items. I also really enjoyed the example solution for problem #1 from class. I think that helped me understand the concept of how a hash function will point to the same "cell" using a mathematical transformation .

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Daniela, you hit the learning goals here. Take a look at my feedback on time/space complexity and top_k_frequent_elements. Let me know if you have questions.

Just FYI you submitted this in the Ruby section. That's why the tests failed.

Comment on lines +3 to 5
// Time Complexity: O(n^2)
// Space Complexity: O(n)
function grouped_anagrams(strings) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 However this is not an O(n^2) solution. Instead it's O(n), if the words are limited in length (like to English words). If the words are not limited it's O(n * m log m) due to sorting.

Comment on lines +30 to 32
// Time Complexity: O(n^2)
// Space Complexity: O(n)
function top_k_frequent_elements(list, k) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 But the time complexity is O(n) time complexity is O(n * k * m) where n is the number of elements and k the number of most frequent elements and m the size of the most frequent element. It can be written more efficiently, but this is an ok solution.

Comment on lines +77 to 79
// Time Complexity: O(n^2)
// Space Complexity: O(n)
function valid_sudoku(table) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One note. Because Sudoku boards never change in size, scale isn't an issue!

Comment on lines +56 to +60
if (highest_freq in counting_hash) {
for (let i = 0; i < counting_hash[highest_freq].length; i++) {
if (output.length === k) {
continue
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of counting down highest_freq each time, you simply find the largest value in the object and then remove that key-value pair. That might speed things up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants